package com.elong.businesstravel.modules.orders.adapter;

import java.util.List;

import com.elong.businesstravel.R;
import com.elong.businesstravel.base.baseadapter.CustomAdapter;
import com.elong.businesstravel.entitys.OrderInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

public class OrdersListAdapter extends CustomAdapter {

	private List<OrderInfo> mOrderInfos;
	
	public OrdersListAdapter(Context context, List<OrderInfo> orderInfos) {
		super(context);
		mOrderInfos = orderInfos;
	}

	@Override
	public int getCount() {
		return mOrderInfos.size();
	}

	@Override
	public Object getItem(int arg0) {
		return mOrderInfos.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		return arg0;
	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		
		if(null == arg1){
			arg1 = LayoutInflater.from(mContext).inflate(R.layout.adapter_orders_list, null);
		}
		
		OrderInfo orderInfo = mOrderInfos.get(arg0);
		
		TextView hotelNameTextView = (TextView)arg1.findViewById(R.id.hotelNametextView);
		hotelNameTextView.setText(orderInfo.hotelname);
		
		TextView dateTextView = (TextView)arg1.findViewById(R.id.dateTextView);
		dateTextView.setText(orderInfo.createtime);
		
		TextView stateTextView = (TextView)arg1.findViewById(R.id.stateTextView);
		stateTextView.setText(orderInfo.orderstate);
		
		return arg1;
	}

}
